Made button-press timeouts which work like key repeat timeouts
authorMichael Natterer <mitch@imendio.com>
Tue, 22 Nov 2005 12:40:15 +0000 (12:40 +0000)
committerMichael Natterer <mitch@src.gnome.org>
Tue, 22 Nov 2005 12:40:15 +0000 (12:40 +0000)
2005-11-22  Michael Natterer  <mitch@imendio.com>

Made button-press timeouts which work like key repeat timeouts
configurable. Addresses bug #142582:

* gtk/gtksettings.c: added properties "gtk-timeout-initial" and
"gtk-timeout-repeat" which defalt to 200/20 (ms).

Use the values from GtkSettings instead of hardcoding them
(the repeat value is either taken as-is for fast repeat or
multiplied by 5 for slow repeat). Changed all places to use these
two standard initial/repeat timings:

* gtk/gtkcalendar.c (unchanged 200/20)
* gtk/gtknotebook.c (unchanged 200/100)
* gtk/gtkpathbar.c (changed from 300/150 to 200/100)
* gtk/gtkrange.c (changed from 250/100 to 200/100)
* gtk/gtkspinbutton.c (unchanged 200/20)

ChangeLog
ChangeLog.pre-2-10
gtk/gtkcalendar.c
gtk/gtknotebook.c
gtk/gtkpathbar.c
gtk/gtkrange.c
gtk/gtksettings.c
gtk/gtkspinbutton.c

index 95107013720fef1b61163a844951d87c72103296..e2128422056c719f4b96663a8ad7b739384441e9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2005-11-22  Michael Natterer  <mitch@imendio.com>
+
+       Made button-press timeouts which work like key repeat timeouts
+       configurable. Addresses bug #142582:
+
+       * gtk/gtksettings.c: added properties "gtk-timeout-initial" and
+       "gtk-timeout-repeat" which defalt to 200/20 (ms).
+
+       Use the values from GtkSettings instead of hardcoding them
+       (the repeat value is either taken as-is for fast repeat or
+       multiplied by 5 for slow repeat). Changed all places to use these
+       two standard initial/repeat timings:
+
+       * gtk/gtkcalendar.c (unchanged 200/20)
+       * gtk/gtknotebook.c (unchanged 200/100)
+       * gtk/gtkpathbar.c (changed from 300/150 to 200/100)
+       * gtk/gtkrange.c (changed from 250/100 to 200/100)
+       * gtk/gtkspinbutton.c (unchanged 200/20)
+
 2005-11-21  Anders Carlsson  <andersca@imendio.com>
 
         * configure.in:
index 95107013720fef1b61163a844951d87c72103296..e2128422056c719f4b96663a8ad7b739384441e9 100644 (file)
@@ -1,3 +1,22 @@
+2005-11-22  Michael Natterer  <mitch@imendio.com>
+
+       Made button-press timeouts which work like key repeat timeouts
+       configurable. Addresses bug #142582:
+
+       * gtk/gtksettings.c: added properties "gtk-timeout-initial" and
+       "gtk-timeout-repeat" which defalt to 200/20 (ms).
+
+       Use the values from GtkSettings instead of hardcoding them
+       (the repeat value is either taken as-is for fast repeat or
+       multiplied by 5 for slow repeat). Changed all places to use these
+       two standard initial/repeat timings:
+
+       * gtk/gtkcalendar.c (unchanged 200/20)
+       * gtk/gtknotebook.c (unchanged 200/100)
+       * gtk/gtkpathbar.c (changed from 300/150 to 200/100)
+       * gtk/gtkrange.c (changed from 250/100 to 200/100)
+       * gtk/gtkspinbutton.c (unchanged 200/20)
+
 2005-11-21  Anders Carlsson  <andersca@imendio.com>
 
         * configure.in:
index d8daeaa574c27e8400e42669fc6ed0270212496d..34d76269e1f12f7118bd83d2bff9dc0e6abe5a4f 100644 (file)
@@ -2286,9 +2286,6 @@ gtk_calendar_expose (GtkWidget        *widget,
  *           Mouse handling             *
  ****************************************/
 
-#define CALENDAR_INITIAL_TIMER_DELAY    200
-#define CALENDAR_TIMER_DELAY            20
-
 static void
 calendar_arrow_action (GtkCalendar *calendar,
                       guint        arrow)
@@ -2327,10 +2324,16 @@ calendar_timer (gpointer data)
 
       if (priv->need_timer)
        {
+          GtkSettings *settings;
+          guint        timeout;
+
+          settings = gtk_widget_get_settings (GTK_WIDGET (calendar));
+          g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL);
+
          priv->need_timer = FALSE;
-         priv->timer = g_timeout_add (CALENDAR_TIMER_DELAY, 
-                                              (GSourceFunc) calendar_timer, 
-                                              (gpointer) calendar);
+         priv->timer = g_timeout_add (timeout,
+                                       (GSourceFunc) calendar_timer,
+                                       (gpointer) calendar);
        }
       else 
        retval = TRUE;
@@ -2351,8 +2354,14 @@ calendar_start_spinning (GtkCalendar *calendar,
   
   if (!priv->timer)
     {
+      GtkSettings *settings;
+      guint        timeout;
+
+      settings = gtk_widget_get_settings (GTK_WIDGET (calendar));
+      g_object_get (settings, "gtk-timeout-initial", &timeout, NULL);
+
       priv->need_timer = TRUE;
-      priv->timer = g_timeout_add (CALENDAR_INITIAL_TIMER_DELAY, 
+      priv->timer = g_timeout_add (timeout,
                                   calendar_timer,
                                   calendar);
     }
index ea7b12f5497aadf099a8070422161522b44ffdb8..af31a0fb92ad8d5a600837e924af2b47ab528d4d 100644 (file)
 #include "gtkalias.h"
 
 
-#define TAB_OVERLAP    2
-#define TAB_CURVATURE  1
-#define ARROW_SIZE     12
-#define ARROW_SPACING  0
-#define NOTEBOOK_INIT_SCROLL_DELAY (200)
-#define NOTEBOOK_SCROLL_DELAY      (100)
+#define TAB_OVERLAP         2
+#define TAB_CURVATURE       1
+#define ARROW_SIZE          12
+#define ARROW_SPACING       0
+#define SCROLL_DELAY_FACTOR 5
 
 
 enum {
@@ -1715,8 +1714,13 @@ gtk_notebook_arrow_button_press (GtkNotebook      *notebook,
       
       if (!notebook->timer)
        {
-         notebook->timer = g_timeout_add (NOTEBOOK_INIT_SCROLL_DELAY, 
-                                          (GSourceFunc) gtk_notebook_timer, 
+          GtkSettings *settings = gtk_widget_get_settings (widget);
+          guint        timeout;
+
+          g_object_get (settings, "gtk-timeout-initial", &timeout, NULL);
+
+         notebook->timer = g_timeout_add (timeout,
+                                          (GSourceFunc) gtk_notebook_timer,
                                           (gpointer) notebook);
          notebook->need_timer = TRUE;
        }
@@ -2584,11 +2588,17 @@ gtk_notebook_timer (GtkNotebook *notebook)
     {
       gtk_notebook_do_arrow (notebook, notebook->click_child);
 
-      if (notebook->need_timer) 
+      if (notebook->need_timer)
        {
+          GtkSettings *settings;
+          guint        timeout;
+
+          settings = gtk_widget_get_settings (GTK_WIDGET (notebook));
+          g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL);
+
          notebook->need_timer = FALSE;
-         notebook->timer = g_timeout_add (NOTEBOOK_SCROLL_DELAY,
-                                          (GSourceFunc) gtk_notebook_timer, 
+         notebook->timer = g_timeout_add (timeout * SCROLL_DELAY_FACTOR,
+                                          (GSourceFunc) gtk_notebook_timer,
                                           (gpointer) notebook);
        }
       else
index ce13d701694bdc6998db7dc0f5841230ca6cc81c..ec62d32d35ccc715d940577d380a90c8fc81c4af 100644 (file)
@@ -48,8 +48,7 @@ typedef enum {
 
 #define BUTTON_DATA(x) ((ButtonData *)(x))
 
-#define SCROLL_TIMEOUT           150
-#define INITIAL_SCROLL_TIMEOUT   300
+#define SCROLL_DELAY_FACTOR 5
 
 static guint path_bar_signals [LAST_SIGNAL] = { 0 };
 
@@ -745,16 +744,19 @@ gtk_path_bar_scroll_timeout (GtkPathBar *path_bar)
 
       if (path_bar->need_timer) 
        {
+          GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (path_bar));
+          guint        timeout;
+
+          g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL);
+
          path_bar->need_timer = FALSE;
 
-         path_bar->timer = g_timeout_add (SCROLL_TIMEOUT,
+         path_bar->timer = g_timeout_add (timeout * SCROLL_DELAY_FACTOR,
                                           (GSourceFunc)gtk_path_bar_scroll_timeout,
                                           path_bar);
-         
        }
       else
        retval = TRUE;
-      
     }
 
   GDK_THREADS_LEAVE ();
@@ -798,8 +800,13 @@ gtk_path_bar_slider_button_press (GtkWidget      *widget,
 
   if (!path_bar->timer)
     {
+      GtkSettings *settings = gtk_widget_get_settings (widget);
+      guint        timeout;
+
+      g_object_get (settings, "gtk-timeout-initial", &timeout, NULL);
+
       path_bar->need_timer = TRUE;
-      path_bar->timer = g_timeout_add (INITIAL_SCROLL_TIMEOUT,
+      path_bar->timer = g_timeout_add (timeout,
                                       (GSourceFunc)gtk_path_bar_scroll_timeout,
                                       path_bar);
     }
index f9c62932a59f23e9883600a0ef557454de0df6aa..f8e409899b69eedc925ee5b64b3fc6a63f9d6d9a 100644 (file)
@@ -37,9 +37,8 @@
 #include "gtkprivate.h"
 #include "gtkalias.h"
 
-#define SCROLL_INITIAL_DELAY 250  /* must hold button this long before ... */
-#define SCROLL_LATER_DELAY   100  /* ... it starts repeating at this rate  */
-#define UPDATE_DELAY         300  /* Delay for queued update */
+#define SCROLL_DELAY_FACTOR 5    /* Scroll repeat multiplier */
+#define UPDATE_DELAY        300  /* Delay for queued update */
 
 enum {
   PROP_0,
@@ -2693,14 +2692,18 @@ second_timeout (gpointer data)
 static gboolean
 initial_timeout (gpointer data)
 {
-  GtkRange *range;
+  GtkRange    *range;
+  GtkSettings *settings;
+  guint        timeout;
 
   GDK_THREADS_ENTER ();
+  settings = gtk_widget_get_settings (GTK_WIDGET (data));
+  g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL);
+
   range = GTK_RANGE (data);
-  range->timer->timeout_id = 
-    g_timeout_add (SCROLL_LATER_DELAY,
-                   second_timeout,
-                   range);
+  range->timer->timeout_id = g_timeout_add (timeout * SCROLL_DELAY_FACTOR,
+                                            second_timeout,
+                                            range);
   GDK_THREADS_LEAVE ();
 
   /* remove self */
@@ -2711,15 +2714,20 @@ static void
 gtk_range_add_step_timer (GtkRange      *range,
                           GtkScrollType  step)
 {
+  GtkSettings *settings;
+  guint        timeout;
+
   g_return_if_fail (range->timer == NULL);
   g_return_if_fail (step != GTK_SCROLL_NONE);
-  
+
+  settings = gtk_widget_get_settings (GTK_WIDGET (range));
+  g_object_get (settings, "gtk-timeout-initial", &timeout, NULL);
+
   range->timer = g_new (GtkRangeStepTimer, 1);
 
-  range->timer->timeout_id =
-    g_timeout_add (SCROLL_INITIAL_DELAY,
-                   initial_timeout,
-                   range);
+  range->timer->timeout_id = g_timeout_add (timeout,
+                                            initial_timeout,
+                                            range);
   range->timer->step = step;
 
   gtk_range_scroll (range, range->timer->step);
index 9daa41f4e456cd61ddadc5434ee9c06d1ba0b85e..4193eadca0beedfa1f900f9abce16c1946480464 100644 (file)
@@ -32,6 +32,9 @@
 #include "x11/gdkx.h"
 #endif
 
+#define DEFAULT_TIMEOUT_INITIAL 200
+#define DEFAULT_TIMEOUT_REPEAT   20
+
 typedef struct _GtkSettingsValuePrivate GtkSettingsValuePrivate;
 
 typedef enum
@@ -79,7 +82,9 @@ enum {
 #endif
   PROP_ALTERNATIVE_BUTTON_ORDER,
   PROP_SHOW_INPUT_METHOD_MENU,
-  PROP_SHOW_UNICODE_MENU
+  PROP_SHOW_UNICODE_MENU,
+  PROP_TIMEOUT_INITIAL,
+  PROP_TIMEOUT_REPEAT
 };
 
 
@@ -406,6 +411,25 @@ gtk_settings_class_init (GtkSettingsClass *class)
                                             NULL);
   g_assert (result == PROP_SHOW_UNICODE_MENU);
 
+  result = settings_install_property_parser (class,
+                                            g_param_spec_int ("gtk-timeout-initial",
+                                                              P_("Start timeout"),
+                                                              P_("Starting value for timeouts, when button is pressed"),
+                                                              0, G_MAXINT, DEFAULT_TIMEOUT_INITIAL,
+                                                              G_PARAM_READWRITE),
+                                            NULL);
+
+  g_assert (result == PROP_TIMEOUT_INITIAL);
+
+  result = settings_install_property_parser (class,
+                                            g_param_spec_int ("gtk-timeout-repeat",
+                                                              P_("Repeat timeout"),
+                                                              P_("Repeat value for timeouts, when button is pressed"),
+                                                              0, G_MAXINT, DEFAULT_TIMEOUT_REPEAT,
+                                                              G_PARAM_READWRITE),
+                                            NULL);
+
+  g_assert (result == PROP_TIMEOUT_REPEAT);
 }
 
 static void
index 2c62c04aa224d9a85efca17ddc4c2b73369312cd..18b1d29e2fe34e45df28cb21386f0587c1c19956 100644 (file)
 #include "gtkintl.h"
 #include "gtkalias.h"
 
-#define MIN_SPIN_BUTTON_WIDTH              30
-#define SPIN_BUTTON_INITIAL_TIMER_DELAY    200
-#define SPIN_BUTTON_TIMER_DELAY            20
-#define MAX_TIMER_CALLS                    5
-#define EPSILON                            1e-10
-#define        MAX_DIGITS                         20
-#define MIN_ARROW_WIDTH                           6
+#define MIN_SPIN_BUTTON_WIDTH 30
+#define MAX_TIMER_CALLS       5
+#define EPSILON               1e-10
+#define        MAX_DIGITS            20
+#define MIN_ARROW_WIDTH       6
 
 enum {
   PROP_0,
@@ -1050,10 +1048,15 @@ start_spinning (GtkSpinButton *spin,
   
   if (!spin->timer)
     {
+      GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (spin));
+      guint        timeout;
+
+      g_object_get (settings, "gtk-timeout-initial", &timeout, NULL);
+
       spin->timer_step = step;
       spin->need_timer = TRUE;
-      spin->timer = g_timeout_add (SPIN_BUTTON_INITIAL_TIMER_DELAY, 
-                                  (GSourceFunc) gtk_spin_button_timer, 
+      spin->timer = g_timeout_add (timeout,
+                                  (GSourceFunc) gtk_spin_button_timer,
                                   (gpointer) spin);
     }
   gtk_spin_button_real_spin (spin, click_child == GTK_ARROW_UP ? step : -step);
@@ -1203,8 +1206,13 @@ gtk_spin_button_timer (GtkSpinButton *spin_button)
 
       if (spin_button->need_timer)
        {
+          GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (spin_button));
+          guint        timeout;
+
+          g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL);
+
          spin_button->need_timer = FALSE;
-         spin_button->timer = g_timeout_add (SPIN_BUTTON_TIMER_DELAY, 
+         spin_button->timer = g_timeout_add (timeout,
                                              (GSourceFunc) gtk_spin_button_timer, 
                                              (gpointer) spin_button);
        }